package com.company;

import cn.hutool.core.io.FileUtil;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;

public class Main2 {


    private static ByteBuffer byteBuffer;

    public static void main(String[] args) throws IOException {


        FileOutputStream fileOutputStream = new FileOutputStream("D:\\123456.txt",true);

        FileChannel channel = fileOutputStream.getChannel();


        byteBuffer = ByteBuffer.allocate(1024);
        byteBuffer.put("你好，我是大叔限速".getBytes(Charset.forName("UTF-8")));
        byteBuffer.flip(); //移动到开头，方便写
        channel.write(byteBuffer);

        channel.close();

    }
}
